extends Node2D

class_name Matrix

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var python_client = null
var client_class = load("res://client.py")

# Called when the node enters the scene tree for the first time.
func _ready():
	
	pass # Replace with function body.

func init_client(server,username):
	python_client = client_class.new()
	python_client.homeserver = server
	python_client.username = username
	add_child(python_client)

func register(password):
	python_client.register(password)
	return true

func login(password):
	return python_client.login2(password)

func get_username():
	return str(python_client.username)
func get_homeserver():
	return str(python_client.homeserver).trim_prefix("https://").trim_prefix("http://")

func create_if_not(room_name):
	return python_client.create_if_not2(room_name)

func join(room_id_or_alias): #returns id
	return str(python_client.join2(room_id_or_alias))

func synchronize():
	python_client.get_first_batch()

#func fetch_new(room_id):
#	python_client.fetch_new_messages(room_id)

func fetch_one():
	return str(python_client.fetch_one())


func start_listen(room_id):
	python_client.start_listen(room_id)

func reset():
	if python_client:
		python_client.queue_free()

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass
